#include "hw_translate.h"
#include "../packet_headers/etherhdr.h"
#include "../Errors/errors.h"
#include <ctype.h>

unsigned char digit_to_byte(unsigned char x) {
	if(x >= '0' && x <= '9')
		return x - '0';
	else if(x >= 'A' && x <= 'F') {
		return x - 'A' + 10;
	}
	else {
		return 0;
	}
}

char * get_hw_addr(const char* str){

	char * buf = new char[ETH_ADDR_LEN];
	int i;
	char c,val;

	for(i=0;i<ETH_ADDR_LEN;i++){
		unsigned char next = 0;
		next += digit_to_byte(str[0]) << 4;
		next += digit_to_byte(str[1]);
		buf[i] = next;
		str += 3;
	}

	return buf;
}
